﻿using SGArchiveSystem7x.App_Code;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace SGArchiveSystem7x.Controllers.Browse
{
    public class LendController : Controller
    {
        // GET: Lend
        public ActionResult Index()
        {
            //获取借出 grid
            var listLend = SGArchiveSystem7x.Models.CColumnsModel.Create_LendColumns();
            ViewBag.lsitLend = listLend;
            return View();
        }

        /// <summary>
        /// 显示我的浏览
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult Get_ajaxLendList()
        {
            var user = SGArchiveSystem7x.App_Code.CSession.Get_User(Session);
            int count = 0;
            var list = SGArchiveSystem7xDB.Linq.T_BInfoDal.Get_BeowsePaperInfo(user.U_RNAME,out count);
            var json = new
            {
                rows = list.ToArray(),
                total = count
            };
            return Json(json, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 分页显示我的浏览
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult Get_ajaxLendListPage(int num, int size)
        {
            var user = SGArchiveSystem7x.App_Code.CSession.Get_User(Session);
            int iStart = (num - 1) * size;
            int count = 0;
            var list = SGArchiveSystem7xDB.Linq.T_BInfoDal.Get_BeowsePaperInfo(user.U_RNAME,out count,iStart, CWebCommons._iPageRows);
            var json = new
            {
                rows = list.ToArray(),
                total = count
            };
            return Json(json, JsonRequestBehavior.AllowGet);
        }
    }
}